package com.qingke.oms.pojo;

import java.util.List;

public class ShoppingCart {
	private int id;
	private int customerId;
	private int shopId;
	private List<ShoppingCartItem> items;
	private double total;
	public ShoppingCart(){
		
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getCustomerId() {
		return customerId;
	}
	public void setCustomerId(int customerId) {
		this.customerId = customerId;
	}
	public int getShopId() {
		return shopId;
	}
	public void setShopId(int shopId) {
		this.shopId = shopId;
	}
	
	public List<ShoppingCartItem> getItems() {
		return items;
	}
	public void setItems(List<ShoppingCartItem> items) {
		this.items = items;
	}
	public double getTotal() {
		return total;
	}
	public void setTotal(double total) {
		this.total = total;
	}
	public void calculateTotal(){
		double count=0;
		for(ShoppingCartItem i:items){
			if(i.getQuantity()!=0){
				count+=(i.getPrice()*i.getQuantity());
			}
		}
		setTotal(count);
	}
	
}
